﻿using System;
using System.Collections.Generic;
using System.Text;
using Fcdbas.Core.WCF.TransFile.Contracts.Enums;
using System.IO;

namespace Fcdbas.Core.WCF.TransFile.Client
{
    public class DownLoadFielInfo
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="localFolder">本地文件夹</param>
        /// <param name="fileTitle">相对路径</param>
        /// <param name="customerFolder">服务器自定义文件夹</param>
        /// <param name="type">文件类型</param>
        public DownLoadFielInfo(SpaceType type, string customerFolder, string localFolder, string fileTitle)
        {
            LocalFolder = localFolder;
            if (!string.IsNullOrEmpty(fileTitle))
            {
                ServerFileTitle = fileTitle;
                LocalFileTitle = fileTitle;
                if (ServerFileTitle.IndexOf(".") > 0)
                {
                    Extension = ServerFileTitle.Substring(ServerFileTitle.IndexOf("."));
                }
                CustomFolder = customerFolder;
                FileType = type;
            }
        }


        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="type">文件类型</param>
        /// <param name="customerFolder">服务器自定义文件夹</param>
        /// <param name="relativePath">服务器相对路径</param>
        /// <param name="localFolder">本地文件夹</param>
        /// <param name="localFileTitle">本地文件名</param>
        public DownLoadFielInfo(SpaceType type, string customerFolder, string relativePath, string localFolder, string localFileTitle)
        {
            LocalFolder = localFolder;
            if (!string.IsNullOrEmpty(relativePath))
            {
                ServerFileTitle = relativePath;
                LocalFileTitle = localFileTitle;
                if (ServerFileTitle.IndexOf(".") > 0)
                {
                    Extension = ServerFileTitle.Substring(ServerFileTitle.IndexOf("."));
                }
                CustomFolder = customerFolder;
                FileType = type;
            }
        }

        /// <summary>
        /// 本地路径
        /// </summary>
        public string LocalPath
        {
            get { return Path.Combine(LocalFolder, LocalFileTitle); }
        }

        public string LocalFolder { get; set; }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string ServerFileTitle { get; set; }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string LocalFileTitle { get; set; }

        /// <summary>
        /// 文件扩展名
        /// </summary>
        public string Extension { get; set; }

        /// <summary>
        /// 文件大小
        /// </summary>
        public long FileSize { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        public SpaceType FileType { get; set; }

        /// <summary>
        /// 用户编码
        /// </summary>
        public string CustomFolder { get; set; }

        /// <summary>
        /// 操作类型
        /// </summary>
        public ToolType ToolType { get; set; }

        public DownLoadFielInfo Clone()
        {
            return this.MemberwiseClone() as DownLoadFielInfo;
        }
    }
}
